#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
#endregion

namespace Toolkit
{
    public class FirstPersonCamera : Camera
    {
        public FirstPersonCamera(Game game)
            : base(game)
        {
        }

        public FirstPersonCamera(Game game, Vector3 startingPosition, float spinSpeed, float moveSpeed)
            : base(game, startingPosition, spinSpeed, moveSpeed)
        {
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            if (inputEnabled)
            {
                movement = Vector3.Zero;
                float oldMoveRate = moveRate;

                if (input.KeyboardState.IsKeyDown(Keys.LeftShift)
                    || input.GamePads[0].Triggers.Left > 0)
                {
                    moveRate *= 5;
                }

                if (input.KeyboardState.IsKeyDown(Keys.A)
                    || (input.GamePads[0].ThumbSticks.Left.X < 0))
                {
                    movement.X--;
                }

                if (input.KeyboardState.IsKeyDown(Keys.D)
                    || (input.GamePads[0].ThumbSticks.Left.X > 0))
                {
                    movement.X++;
                }

                if (input.KeyboardState.IsKeyDown(Keys.S)
                    || (input.GamePads[0].ThumbSticks.Left.Y < 0))
                {
                    movement.Z++;
                }

                if (input.KeyboardState.IsKeyDown(Keys.W)
                    || (input.GamePads[0].ThumbSticks.Left.Y > 0))
                {
                    movement.Z--;
                }

                if (movement.LengthSquared() != 0)
                    movement.Normalize();

                base.Update(gameTime);

                moveRate = oldMoveRate;
            }
        }
    }
}
